package com.jifeng.br.pjj.bookreader.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jifeng.br.pjj.bookreader.entity.FeedbackEntity;
import com.jifeng.br.pjj.bookreader.mapper.FeedbackMapper;
import com.jifeng.br.pjj.bookreader.service.FeedbackService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 意见反馈表 服务实现类
 * </p>
 *
 * @author 机蜂
 * @since 2023-07-11
 */
@Service
@Transactional
public class FeedbackServiceImpl extends ServiceImpl<FeedbackMapper, FeedbackEntity> implements FeedbackService {

    @Override
    public IPage<FeedbackEntity> getPage(int page, int limit, FeedbackEntity feedback) {
        return this.page(new Page<>(page, limit), new QueryWrapper<FeedbackEntity>()
                .eq(feedback.getStatus() != null, "status", feedback.getStatus())
                .eq(feedback.getUserId() != null, "user_id", feedback.getUserId())
                .eq(feedback.getAnonymous() != null, "anonymous", feedback.getAnonymous())
                .orderByDesc("id")
        );
    }
}
